package com.byxy.shop.config;

import com.byxy.shop.interceptor.VerifyInterceptor;
import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.LocaleResolver;

@Configuration
public class CustomConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //配置静态资源路径
        registry.addResourceHandler("/admin/**").addResourceLocations("classpath:/static/admin/");
        registry.addResourceHandler("/mall/**").addResourceLocations("classpath:/static/mall/");
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new VerifyInterceptor()).addPathPatterns("/login").addPathPatterns("/register");
    }
    //自定义的国际化组件就生效了！菜鸡华
    @Bean
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }
}

